// echo_client.cpp: test for ClientSocket
#include "ServerSocket.h"
#include "SocketException.h"
#include <iostream>
#include <string>
using namespace std;

int main ( int argc, char* argv[] )
{
    try
    {
        // 1.create,bind socket
        ServerSocket server_socket( 30000 );
        
        // 2.accept a connection from client
        ServerSocket com_socket;
        server_socket.accept( com_socket );
        
        // 3.recive message from client
        string request;
        com_socket>>request;
        cout<<"client:"<<request<<endl;

        // send to client
        string reply("I am server!");
        com_socket<<reply;
        cout<<"server:"<<reply<<endl;        
    }
    catch ( SocketException& ex)
    {
        cout << ex.description() << endl;
    }
}

